"""
题目：判断目标值是否在双链表中，存在返回 True，否则返回 False。
"""

class Node:
    def __init__(self, val=0, prev=None, next=None):
        self.val = val
        self.prev = prev
        self.next = next

def contains(head, target):
    """判断双链表中是否存在目标值"""
    current = head
    while current:
        if current.val == target:
            return True
        current = current.next
    return False

def create_doubly_linked_list(arr):
    if not arr:
        return None
    head = Node(arr[0])
    current = head
    for val in arr[1:]:
        new_node = Node(val)
        current.next = new_node
        new_node.prev = current
        current = new_node
    return head

# 测试
if __name__ == "__main__":
    head = create_doubly_linked_list([2, 4, 6, 8])
    print(contains(head, 6))  # 输出: True
    print(contains(head, 3))  # 输出: False
    print(contains(create_doubly_linked_list([]), 0))  # 输出: False